import { createRouter, createWebHistory } from 'vue-router';

const routes = [
  {
    path: '/',
    name: 'Home',
    component: () => import('@/views/Home'),
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login'),
  },
  {
    path: '/signup',
    name: 'Signup',
    component: () => import('@/views/Signup'),
  },
  {
    path: '/column/:id',
    name: 'Column',
    component: () => import('@/views/Column'),
  },
  {
    path: '/posts/:id',
    name: 'Posts',
    component: () => import('@/views/Posts'),
  },
  {
    path: '/article',
    name: 'Article',
    component: () => import('@/views/Article'),
    meta: {
      requiredLogin: true,
    },
  },
  {
    path: '/:catchAll(.*)',
    name: 'NotFound',
    redirect: '/',
  },
];
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

// export function resetRouter() {
//   const newRouter = createRouter();
//   router.matcher = newRouter.matcher; // reset router
// }

export default router;
